/**
 * 郭楠project
 * com.gn.service
 * GoodsServiceImpl.java
 * 创建人:TonyGuo 
 * 时间：2017年3月23日-下午2:36:59 
 * 2017Tm公司-版权所有
 */
package com.gn.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.gn.dao.AdminUserDAO;
import com.gn.dao.CommentDao;
import com.gn.dao.GoodsDAO;
import com.gn.entity.Goods;
import com.gn.serviceImpl.AdminUserServiceImpl;

/**
 * 
 * GoodsServiceImpl
 * 创建人:TonyGuo
 * 时间：2017年3月23日-下午2:36:59 
 * @version 1.0.0
 * 
 */
@Service
public class GoodsServiceImpl implements GoodsService {
private static final Logger logger=LoggerFactory.getLogger(AdminUserServiceImpl.class);
	
	@Resource
	private GoodsDAO goodsDAO;
	@Resource
	private CommentDao commentDao;
	
	/* (non-Javadoc)
	 * @see com.gn.service.GoodsService#addGoods(com.gn.entity.Goods)
	 */
	@Override
	public boolean addGoods(Goods goods) {
		// TODO Auto-generated method stub
		return goodsDAO.addGoods(goods);
	}

	/* (non-Javadoc)
	 * @see com.gn.service.GoodsService#update(com.gn.entity.Goods)
	 */
	@Override
	public boolean update(Goods goods) {
		// TODO Auto-generated method stub
		return goodsDAO.update(goods);
	}

	/* (non-Javadoc)
	 * @see com.gn.service.GoodsService#delete(java.lang.String)
	 */
	@Override
	public boolean delete(String id) {
		// TODO Auto-generated method stub
		return goodsDAO.delete(id);
	}

	/* (non-Javadoc)
	 * @see com.gn.service.GoodsService#findGoodsById(java.lang.String)
	 */
	@Override
	public Goods findGoodsById(String id) {
		// TODO Auto-generated method stub
		Integer c=commentDao.findGoodsCommentCount(id);
		Goods goods=goodsDAO.findGoodsById(id);
		if(goods!=null){
			goods.setCommentCount(String.valueOf(c));
		}
		return goods;
	}

	/* (non-Javadoc)
	 * @see com.gn.service.GoodsService#findAll()
	 */
	@Override
	public List<Goods> findAll(String searcnCnt) {
		// TODO Auto-generated method stub
		return goodsDAO.findAll(searcnCnt);
	}

	/* (non-Javadoc)
	 * @see com.gn.service.GoodsService#findTotalRecords()
	 */
	@Override
	public Integer findTotalRecords() {
		// TODO Auto-generated method stub
		return goodsDAO.findTotalRecords();
	}
	
}
